<!-- 参考官方文档 -->
<template>
    <view class="">
        <view class="">
            <image src="../../../common/image/logo.png" @click="onPreview"></image>
        </view>
        <view class="">
            <button @click="onSave">保存图片</button>
        </view>
    </view>
</template>

<script lang="ts" setup>
    //预览
    function onPreview() {
        let urls = ["../../../common/image/logo.png"];
        uni.previewImage({
            //图片位置
            current: 0,
            //图片集合
            urls: urls
        });
    };

    //保存图片
    function onSave() {
        // #ifndef H5
        //下载图片
        uni.getImageInfo({
            src: "https://cdn.qingnian8.com/public/xxmBizhi/20240508/1715148642233_1.jpg",
            success: res => {
                console.log(res)
                //保存图片
                uni.saveImageToPhotosAlbum({
                    filePath: res.path,
                });
            }
        });
        // #endif
    }
</script>

<style lang="scss" scoped>

</style>